package com.newhis.controller.login;

import com.newhis.service.login.LoginService;
import com.newhis.utils.GroovyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.lang.reflect.InvocationTargetException;

@RestController
@RequestMapping("login")
public class LoginController {
    @Autowired
    private LoginService loginService;
    @GetMapping("login")
    private ResponseEntity<?> login(@RequestParam String username, @RequestParam String password){
        loginService.login(username, password);
        return ResponseEntity.ok("success");
    }

    @GetMapping("test")
    public ResponseEntity<?> test() throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
        GroovyUtil.loadScript("1", "public int sum(){\n" +
                "        return 5;\n" +
                "    }", 1);
        return ResponseEntity.ok("success");
    }


}
